package Objects;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import Util.FilterNumber;

public class Score {

	private int currentScore;
	private Image iconDezMil;
	private Image iconMili;
	private Image iconCent;
	private Image iconDez;
	private Image iconUni;
	int largura;
	int altura;
	FilterNumber filterNumber;
	
	public Score(Dimension area) {
		
		currentScore = 0;
		largura = (int)area.getWidth();
		altura = (int)area.getHeight();
		filterNumber = new FilterNumber();
	}
	
	public void draw(Graphics g) {
		
		g.drawImage(iconUni, largura-30, 600, null);
		g.drawImage(iconDez, largura-60, 600, null);
		g.drawImage(iconCent, largura-90, 600, null);
		g.drawImage(iconMili, largura-120, 600, null);
		g.drawImage(iconDezMil, largura-150, 600, null);
	}
	
	public void addScore(int x) {
		currentScore += x;
	}
	
	public void updateScore(){
		
        double dez, cent, mil, dezmil, mod;
        mod = currentScore;
        dezmil = mod/10000;        
        mod = currentScore%10000;
        mil = mod/1000;
        mod = currentScore%1000;
        cent = mod/100;
        mod = currentScore%100;
        dez = mod/10;
        mod = currentScore%10;
        iconDezMil = filterNumber.setImage( (int)dezmil, 2);
        iconMili = filterNumber.setImage( (int)mil, 2);
        iconCent = filterNumber.setImage( (int)cent, 2);
        iconDez = filterNumber.setImage( (int)dez, 2);
        iconUni = filterNumber.setImage( (int)mod, 2);
	}
	
	public void drawFinish(Graphics g) {
		
		g.drawImage(iconUni, 530, 350, null);
		g.drawImage(iconDez, 500, 350, null);
		g.drawImage(iconCent, 470, 350, null);
		g.drawImage(iconMili, 440, 350, null);
		g.drawImage(iconDezMil, 410, 350, null);
	}
	
	public int getCurrentScore() {
		return currentScore;
	}
}
